package com.atguigu.day01;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class demo {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        test1(env);
        test2(env);
        test3(env);
    }

    public static void test1(StreamExecutionEnvironment env) throws Exception {
        DataStreamSource<Integer> integerDataStreamSource = env.fromElements(11);
        SingleOutputStreamOperator<Integer> map = integerDataStreamSource.map(r -> r);
        map.print();
        env.execute();


    }

    public static void test2(StreamExecutionEnvironment env) throws Exception {
        DataStreamSource<Integer> integerDataStreamSource = env.fromElements(11);
        SingleOutputStreamOperator<Integer> map = integerDataStreamSource.map(r -> r);
        map.print();
        env.execute();

    }
    public static void test3(StreamExecutionEnvironment env) throws Exception {
//        DataStreamSource<Integer> integerDataStreamSource = env.fromElements(11);
        DataStreamSource<String> stringDataStreamSource = env.socketTextStream("hadoop102", 9999);
        SingleOutputStreamOperator<String> map = stringDataStreamSource.map(r -> r);
        map.print();
        env.execute();

    }
}
